﻿using Chats.BE.Controllers.Public.ModelInfo.DTOs;
using Chats.BE.DB;
using Chats.BE.DB.Enums;
using Microsoft.AspNetCore.Mvc;

namespace Chats.BE.Controllers.Public.ModelInfo;

[ResponseCache(CacheProfileName = "ModelInfo")]
public class ModelInfoController : ControllerBase
{
    [HttpGet, Route("api/model-provider")]
    public ActionResult<short[]> List()
    {
        short[] data = ModelProviderInfo.GetAllProviderIds()
            .Select(x => (short)x)
            .ToArray();
        return Ok(data);
    }

    [HttpGet, Route("api/model-provider/{modelProviderId:int}/initial-config")]
    public ActionResult<InitialModelKeyConfigDto> GetInitialConfig(short modelProviderId)
    {
        var provider = (DBModelProvider)modelProviderId;
        if (!ModelProviderInfo.IsValidProviderId(provider))
        {
            return NotFound();
        }
        
        var data = new InitialModelKeyConfigDto
        {
            InitialHost = ModelProviderInfo.GetInitialHost(provider),
            InitialSecret = ModelProviderInfo.GetInitialSecret(provider),
        };
        return Ok(data);
    }
}